package Test08;

//网络编程

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

//TCP协议，接收数据
//服务器端（Server）

public class Test13 {
    public static void main(String[] args) throws IOException {

        //1、创建ServerSocket对象
        ServerSocket ss = new ServerSocket(22222);

        //2、监听客户端的连接
        Socket socket = ss.accept();

        //3、从连接通道获取输入流
        InputStream is = socket.getInputStream();

        //4、读取数据
        int b;
        while ((b = is.read()) != -1) {
            System.out.println((char) b);
        }

        //5、释放资源
        is.close();
        socket.close();
        ss.close();
    }
}
